Skip to content

Validate CA6 mode and humidity setter inputs - #2096

Open
Aulos wants to merge 1 commit into
rytilahti:masterfrom
Aulos:fix-ca6-setter-validation
Open

Aulos wants to merge 1 commit into
rytilahti:masterfrom
Aulos:fix-ca6-setter-validation

Conversation

@Aulos

@Aulos Aulos commented Nov 3, 2026

Copy link
Copy Markdown

Summary

CA6's set_mode was annotated with the CA4 enum and accepted it at runtime. Passing OperationMode.Auto sent 0, which means Favorite on CA6. Require OperationModeCA6 and reject incompatible enums before sending a command.

Also reject fractional humidity targets instead of silently truncating them. Integral floats such as 45.0 remain supported and are encoded as integers.

CA4 Auto enum -> ValueError, no request
CA6 Auto enum -> mode 1
humidity 45.5 -> ValueError, no request
humidity 45.0 -> integer 45

Follow-up to #1884 and #1885; this does not add duplicate CA6 support.

Evidence

  • Before: three regression cases fail, including wrong-enum mode selection and fractional humidity acceptance.
  • After: all 94 zhimi humidifier tests pass; all pre-commit checks pass, including mypy.
  • Validation is automated with mocked transport. This patch has not been tested on the CA6 hardware.

Merge Danger

Door: Two-way.

Blast Radius: CA6 setters. Callers passing another model's enum or fractional targets now receive ValueError. Valid CA6 modes and integral targets keep their existing wire encoding. CA4 is unchanged.

Prepared with AI assistance; no device credentials or account identifiers are included.

@codecov

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.33%. Comparing base (9a00e08) to head (7af1bc7).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2096      +/-   ##
==========================================
+ Coverage   84.31%   84.33%   +0.01%     
==========================================
  Files         201      201              
  Lines       20656    20676      +20     
  Branches     1121     1122       +1     
==========================================
+ Hits        17417    17437      +20     
  Misses       3047     3047              
  Partials      192      192              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@Aulos
Aulos force-pushed the fix-ca6-setter-validation branch from 1145273 to 7af1bc7 Compare November 26, 2026 13:51

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant